let count = 0;
$(".item p img").click(function(){
    count++;
    if(count%2==0){
        $(this).parent().siblings().show();
       
    }else{
        $(this).parent().siblings().hide();
    }
});
var user = getCookie("username");
$.get("./goodsAndShoppingCart/getGoodsList.php", {"typeId": "005"}, function (data) {
    Title(data);
    $("button").click(function(){
        var id = $(this).children().text();
        if (user !='') {
            $.post("./goodsAndShoppingCart/addShoppingCart.php", {
                "vipName":user,"goodsId":id,"goodsCount":"5"
            }, function () {
                alert("添加成功");
            });
        }else{
            alert("添加失败！请先登录");
            location.href="login.html";
            return false;
        }
    });
}, "json");
function Title(data) {
    let str = '';
    // let arr = [];
    for (let i = 0; i < data.length; i++) {
        str += ` <li class="aaa">
        <a href ="detail.html?id=${data[i].goodsId}">
            <img src="${data[i].goodsImg}" alt=""></a>
           <p>${data[i].goodsDesc}</p>
           <h5>${data[i].goodsName}</h5>
           <div class="text">
            <i class="iconfont icon-shoucangjia"></i>
            <i class="iconfont icon-shoucangjia"></i>
            <i class="iconfont icon-shoucangjia"></i>
            <i class="iconfont icon-shoucangjia"></i>
            <i class="iconfont icon-shoucangjia"></i>
            <b></b>
            <p>￥<span style="margin-left: 0">${data[i].goodsPrice}</span></p>
          </div>
         <button>加入购物车<span style="display:none;">${data[i].goodsId}</span></button>
       </li>`;
        // arr += str;
    }
    $(".right ul").prepend(str);
        
}

